package com.bumptech.glide;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.view.animation.Animation;
import android.widget.ImageView;
import com.bumptech.glide.load.Encoder;
import com.bumptech.glide.load.Key;
import com.bumptech.glide.load.MultiTransformation;
import com.bumptech.glide.load.ResourceDecoder;
import com.bumptech.glide.load.ResourceEncoder;
import com.bumptech.glide.load.Transformation;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.load.resource.UnitTransformation;
import com.bumptech.glide.load.resource.transcode.ResourceTranscoder;
import com.bumptech.glide.manager.Lifecycle;
import com.bumptech.glide.manager.RequestTracker;
import com.bumptech.glide.provider.ChildLoadProvider;
import com.bumptech.glide.provider.LoadProvider;
import com.bumptech.glide.request.FutureTarget;
import com.bumptech.glide.request.GenericRequest;
import com.bumptech.glide.request.Request;
import com.bumptech.glide.request.RequestCoordinator;
import com.bumptech.glide.request.RequestFutureTarget;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.ThumbnailRequestCoordinator;
import com.bumptech.glide.request.animation.GlideAnimationFactory;
import com.bumptech.glide.request.animation.NoAnimation;
import com.bumptech.glide.request.animation.ViewAnimationFactory;
import com.bumptech.glide.request.animation.ViewPropertyAnimation.Animator;
import com.bumptech.glide.request.animation.ViewPropertyAnimationFactory;
import com.bumptech.glide.request.target.PreloadTarget;
import com.bumptech.glide.request.target.Target;
import com.bumptech.glide.signature.EmptySignature;
import com.bumptech.glide.util.Util;
import java.io.File;

public class GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType>
  implements Cloneable
{
  private GlideAnimationFactory<TranscodeType> animationFactory = NoAnimation.getFactory();
  protected final Context context;
  private DiskCacheStrategy diskCacheStrategy = DiskCacheStrategy.RESULT;
  private int errorId;
  private Drawable errorPlaceholder;
  private Drawable fallbackDrawable;
  private int fallbackResource;
  protected final Glide glide;
  private boolean isCacheable = true;
  private boolean isModelSet;
  private boolean isThumbnailBuilt;
  private boolean isTransformationSet;
  protected final Lifecycle lifecycle;
  private ChildLoadProvider<ModelType, DataType, ResourceType, TranscodeType> loadProvider;
  private ModelType model;
  protected final Class<ModelType> modelClass;
  private int overrideHeight = -1;
  private int overrideWidth = -1;
  private Drawable placeholderDrawable;
  private int placeholderId;
  private Priority priority = null;
  private RequestListener<? super ModelType, TranscodeType> requestListener;
  protected final RequestTracker requestTracker;
  private Key signature = EmptySignature.obtain();
  private Float sizeMultiplier = Float.valueOf(1.0F);
  private Float thumbSizeMultiplier;
  private GenericRequestBuilder<?, ?, ?, TranscodeType> thumbnailRequestBuilder;
  protected final Class<TranscodeType> transcodeClass;
  private Transformation<ResourceType> transformation = UnitTransformation.get();

  GenericRequestBuilder(Context paramContext, Class<ModelType> paramClass, LoadProvider<ModelType, DataType, ResourceType, TranscodeType> paramLoadProvider, Class<TranscodeType> paramClass1, Glide paramGlide, RequestTracker paramRequestTracker, Lifecycle paramLifecycle)
  {
    this.context = paramContext;
    this.modelClass = paramClass;
    this.transcodeClass = paramClass1;
    this.glide = paramGlide;
    this.requestTracker = paramRequestTracker;
    this.lifecycle = paramLifecycle;
    ChildLoadProvider localChildLoadProvider = null;
    if (paramLoadProvider != null)
      localChildLoadProvider = new ChildLoadProvider(paramLoadProvider);
    this.loadProvider = localChildLoadProvider;
    if (paramContext == null)
      throw new NullPointerException("Context can't be null");
    if ((paramClass != null) && (paramLoadProvider == null))
      throw new NullPointerException("LoadProvider must not be null");
  }

  GenericRequestBuilder(LoadProvider<ModelType, DataType, ResourceType, TranscodeType> paramLoadProvider, Class<TranscodeType> paramClass, GenericRequestBuilder<ModelType, ?, ?, ?> paramGenericRequestBuilder)
  {
    this(paramGenericRequestBuilder.context, paramGenericRequestBuilder.modelClass, paramLoadProvider, paramClass, paramGenericRequestBuilder.glide, paramGenericRequestBuilder.requestTracker, paramGenericRequestBuilder.lifecycle);
    this.model = paramGenericRequestBuilder.model;
    this.isModelSet = paramGenericRequestBuilder.isModelSet;
    this.signature = paramGenericRequestBuilder.signature;
    this.diskCacheStrategy = paramGenericRequestBuilder.diskCacheStrategy;
    this.isCacheable = paramGenericRequestBuilder.isCacheable;
  }

  private Request buildRequest(Target<TranscodeType> paramTarget)
  {
    if (this.priority == null)
      this.priority = Priority.NORMAL;
    return buildRequestRecursive(paramTarget, null);
  }

  private Request buildRequestRecursive(Target<TranscodeType> paramTarget, ThumbnailRequestCoordinator paramThumbnailRequestCoordinator)
  {
    if (this.thumbnailRequestBuilder != null)
    {
      if (this.isThumbnailBuilt)
        throw new IllegalStateException("You cannot use a request as both the main request and a thumbnail, consider using clone() on the request(s) passed to thumbnail()");
      if (this.thumbnailRequestBuilder.animationFactory.equals(NoAnimation.getFactory()))
        this.thumbnailRequestBuilder.animationFactory = this.animationFactory;
      if (this.thumbnailRequestBuilder.priority == null)
        this.thumbnailRequestBuilder.priority = getThumbnailPriority();
      if ((Util.isValidDimensions(this.overrideWidth, this.overrideHeight)) && (!Util.isValidDimensions(this.thumbnailRequestBuilder.overrideWidth, this.thumbnailRequestBuilder.overrideHeight)))
        this.thumbnailRequestBuilder.override(this.overrideWidth, this.overrideHeight);
      ThumbnailRequestCoordinator localThumbnailRequestCoordinator2 = new ThumbnailRequestCoordinator(paramThumbnailRequestCoordinator);
      Request localRequest1 = obtainRequest(paramTarget, this.sizeMultiplier.floatValue(), this.priority, localThumbnailRequestCoordinator2);
      this.isThumbnailBuilt = true;
      Request localRequest2 = this.thumbnailRequestBuilder.buildRequestRecursive(paramTarget, localThumbnailRequestCoordinator2);
      this.isThumbnailBuilt = false;
      localThumbnailRequestCoordinator2.setRequests(localRequest1, localRequest2);
      return localThumbnailRequestCoordinator2;
    }
    if (this.thumbSizeMultiplier != null)
    {
      ThumbnailRequestCoordinator localThumbnailRequestCoordinator1 = new ThumbnailRequestCoordinator(paramThumbnailRequestCoordinator);
      localThumbnailRequestCoordinator1.setRequests(obtainRequest(paramTarget, this.sizeMultiplier.floatValue(), this.priority, localThumbnailRequestCoordinator1), obtainRequest(paramTarget, this.thumbSizeMultiplier.floatValue(), getThumbnailPriority(), localThumbnailRequestCoordinator1));
      return localThumbnailRequestCoordinator1;
    }
    return obtainRequest(paramTarget, this.sizeMultiplier.floatValue(), this.priority, paramThumbnailRequestCoordinator);
  }

  private Priority getThumbnailPriority()
  {
    if (this.priority == Priority.LOW)
      return Priority.NORMAL;
    if (this.priority == Priority.NORMAL)
      return Priority.HIGH;
    return Priority.IMMEDIATE;
  }

  private Request obtainRequest(Target<TranscodeType> paramTarget, float paramFloat, Priority paramPriority, RequestCoordinator paramRequestCoordinator)
  {
    return GenericRequest.obtain(this.loadProvider, this.model, this.signature, this.context, paramPriority, paramTarget, paramFloat, this.placeholderDrawable, this.placeholderId, this.errorPlaceholder, this.errorId, this.fallbackDrawable, this.fallbackResource, this.requestListener, paramRequestCoordinator, this.glide.getEngine(), this.transformation, this.transcodeClass, this.isCacheable, this.animationFactory, this.overrideWidth, this.overrideHeight, this.diskCacheStrategy);
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> animate(int paramInt)
  {
    return animate(new ViewAnimationFactory(this.context, paramInt));
  }

  @Deprecated
  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> animate(Animation paramAnimation)
  {
    return animate(new ViewAnimationFactory(paramAnimation));
  }

  GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> animate(GlideAnimationFactory<TranscodeType> paramGlideAnimationFactory)
  {
    if (paramGlideAnimationFactory == null)
      throw new NullPointerException("Animation factory must not be null!");
    this.animationFactory = paramGlideAnimationFactory;
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> animate(ViewPropertyAnimation.Animator paramAnimator)
  {
    return animate(new ViewPropertyAnimationFactory(paramAnimator));
  }

  void applyCenterCrop()
  {
  }

  void applyFitCenter()
  {
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> cacheDecoder(ResourceDecoder<File, ResourceType> paramResourceDecoder)
  {
    if (this.loadProvider != null)
      this.loadProvider.setCacheDecoder(paramResourceDecoder);
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> clone()
  {
    try
    {
      GenericRequestBuilder localGenericRequestBuilder = (GenericRequestBuilder)super.clone();
      if (this.loadProvider != null);
      for (ChildLoadProvider localChildLoadProvider = this.loadProvider.clone(); ; localChildLoadProvider = null)
      {
        localGenericRequestBuilder.loadProvider = localChildLoadProvider;
        return localGenericRequestBuilder;
      }
    }
    catch (CloneNotSupportedException localCloneNotSupportedException)
    {
      throw new RuntimeException(localCloneNotSupportedException);
    }
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> decoder(ResourceDecoder<DataType, ResourceType> paramResourceDecoder)
  {
    if (this.loadProvider != null)
      this.loadProvider.setSourceDecoder(paramResourceDecoder);
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> diskCacheStrategy(DiskCacheStrategy paramDiskCacheStrategy)
  {
    this.diskCacheStrategy = paramDiskCacheStrategy;
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> dontAnimate()
  {
    return animate(NoAnimation.getFactory());
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> dontTransform()
  {
    return transform(new Transformation[] { UnitTransformation.get() });
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> encoder(ResourceEncoder<ResourceType> paramResourceEncoder)
  {
    if (this.loadProvider != null)
      this.loadProvider.setEncoder(paramResourceEncoder);
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> error(int paramInt)
  {
    this.errorId = paramInt;
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> error(Drawable paramDrawable)
  {
    this.errorPlaceholder = paramDrawable;
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> fallback(int paramInt)
  {
    this.fallbackResource = paramInt;
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> fallback(Drawable paramDrawable)
  {
    this.fallbackDrawable = paramDrawable;
    return this;
  }

  public FutureTarget<TranscodeType> into(int paramInt1, int paramInt2)
  {
    final RequestFutureTarget localRequestFutureTarget = new RequestFutureTarget(this.glide.getMainHandler(), paramInt1, paramInt2);
    this.glide.getMainHandler().post(new Runnable()
    {
      public void run()
      {
        if (!localRequestFutureTarget.isCancelled())
          GenericRequestBuilder.this.into(localRequestFutureTarget);
      }
    });
    return localRequestFutureTarget;
  }

  public Target<TranscodeType> into(ImageView paramImageView)
  {
    Util.assertMainThread();
    if (paramImageView == null)
      throw new IllegalArgumentException("You must pass in a non null View");
    if ((!this.isTransformationSet) && (paramImageView.getScaleType() != null))
      switch (2.$SwitchMap$android$widget$ImageView$ScaleType[paramImageView.getScaleType().ordinal()])
      {
      default:
      case 1:
      case 2:
      case 3:
      case 4:
      }
    while (true)
    {
      return into(this.glide.buildImageViewTarget(paramImageView, this.transcodeClass));
      applyCenterCrop();
      continue;
      applyFitCenter();
    }
  }

  public <Y extends Target<TranscodeType>> Y into(Y paramY)
  {
    Util.assertMainThread();
    if (paramY == null)
      throw new IllegalArgumentException("You must pass in a non null Target");
    if (!this.isModelSet)
      throw new IllegalArgumentException("You must first set a model (try #load())");
    Request localRequest1 = paramY.getRequest();
    if (localRequest1 != null)
    {
      localRequest1.clear();
      this.requestTracker.removeRequest(localRequest1);
      localRequest1.recycle();
    }
    Request localRequest2 = buildRequest(paramY);
    paramY.setRequest(localRequest2);
    this.lifecycle.addListener(paramY);
    this.requestTracker.runRequest(localRequest2);
    return paramY;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> listener(RequestListener<? super ModelType, TranscodeType> paramRequestListener)
  {
    this.requestListener = paramRequestListener;
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> load(ModelType paramModelType)
  {
    this.model = paramModelType;
    this.isModelSet = true;
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> override(int paramInt1, int paramInt2)
  {
    if (!Util.isValidDimensions(paramInt1, paramInt2))
      throw new IllegalArgumentException("Width and height must be Target#SIZE_ORIGINAL or > 0");
    this.overrideWidth = paramInt1;
    this.overrideHeight = paramInt2;
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> placeholder(int paramInt)
  {
    this.placeholderId = paramInt;
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> placeholder(Drawable paramDrawable)
  {
    this.placeholderDrawable = paramDrawable;
    return this;
  }

  public Target<TranscodeType> preload()
  {
    return preload(-2147483648, -2147483648);
  }

  public Target<TranscodeType> preload(int paramInt1, int paramInt2)
  {
    return into(PreloadTarget.obtain(paramInt1, paramInt2));
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> priority(Priority paramPriority)
  {
    this.priority = paramPriority;
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> signature(Key paramKey)
  {
    if (paramKey == null)
      throw new NullPointerException("Signature must not be null");
    this.signature = paramKey;
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> sizeMultiplier(float paramFloat)
  {
    if ((paramFloat < 0.0F) || (paramFloat > 1.0F))
      throw new IllegalArgumentException("sizeMultiplier must be between 0 and 1");
    this.sizeMultiplier = Float.valueOf(paramFloat);
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> skipMemoryCache(boolean paramBoolean)
  {
    if (!paramBoolean);
    for (boolean bool = true; ; bool = false)
    {
      this.isCacheable = bool;
      return this;
    }
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> sourceEncoder(Encoder<DataType> paramEncoder)
  {
    if (this.loadProvider != null)
      this.loadProvider.setSourceEncoder(paramEncoder);
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> thumbnail(float paramFloat)
  {
    if ((paramFloat < 0.0F) || (paramFloat > 1.0F))
      throw new IllegalArgumentException("sizeMultiplier must be between 0 and 1");
    this.thumbSizeMultiplier = Float.valueOf(paramFloat);
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> thumbnail(GenericRequestBuilder<?, ?, ?, TranscodeType> paramGenericRequestBuilder)
  {
    if (equals(paramGenericRequestBuilder))
      throw new IllegalArgumentException("You cannot set a request as a thumbnail for itself. Consider using clone() on the request you are passing to thumbnail()");
    this.thumbnailRequestBuilder = paramGenericRequestBuilder;
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> transcoder(ResourceTranscoder<ResourceType, TranscodeType> paramResourceTranscoder)
  {
    if (this.loadProvider != null)
      this.loadProvider.setTranscoder(paramResourceTranscoder);
    return this;
  }

  public GenericRequestBuilder<ModelType, DataType, ResourceType, TranscodeType> transform(Transformation<ResourceType>[] paramArrayOfTransformation)
  {
    this.isTransformationSet = true;
    if (paramArrayOfTransformation.length == 1)
    {
      this.transformation = paramArrayOfTransformation[0];
      return this;
    }
    this.transformation = new MultiTransformation(paramArrayOfTransformation);
    return this;
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.bumptech.glide.GenericRequestBuilder
 * JD-Core Version:    0.6.2
 */